<%
DIRECTIVE SAFE_OUTPUT_OPEN;
var headContent = {
include("/pages/template/head.html"){}
%>
<script type="text/javascript">
    var oper = {
        save:function(id){
            if(!validForm()) {
                return false;
            }
            var url = 'system/cxuser/save/'+id;
            form1.action = url;
            form1.submit();
            return true;
        },
        setDepartmentnames:function(){
	        var departmentname=$("#departmentId option:selected").text();
	        $("#departmentnames").val(departmentname);
        }
    };

</script>

<%
};
var bodyContent = {
%>
<form name="form1" action="" method="post" class="form-horizontal"
	  role="form" >
	<input type="hidden" name="user.ids" value="${user.ids}" />
	<input type="hidden" name="userInfo.ids" value="${userInfo.ids}" />
	<input id = "departmentnames" type="hidden" name="user.departmentnames" value="${user.departmentnames}" />

	<table class="table">
		<% // 列表头部 %>
		<tr>
			<td>用户类型</td>
			<td>
				<select name="user.TYPE" class="form-control" valid="vselect" placeholder="用户类型">
					<option value="-1">请选择</option>
					<option value="0" ${user.TYPE=="0"?"selected":"" }>管理员</option>
					<option value="1" ${user.TYPE=="1"?"selected":"" }>普通用户</option>
                    <option value="2" ${user.TYPE=="2"?"selected":"" }>API用户</option>
                    <option value="3" ${user.TYPE=="3"?"selected":"" }>其他用户</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>部门</td>
			<td>
				<select id= "departmentId" name="user.departmentId" class="form-control" valid="vselect" placeholder="部门" onchange = "oper.setDepartmentnames();">
				<option value="100">全国</option>
				${selectParentDepartments }
				</select>
			</td>
		</tr>
		<tr>
			<td>绑定客户</td>
			<td>
			<select name="user.customerId" class="form-control" valid="vselect" >
				<option value="0">请选择客户</option>
				${selectCustomer }
				</select>
				
			</td>
		</tr>
		<tr>
			<td>登录名</td>
			<td>
				<input class="form-control" type="text" name="user.username"
					   value="${user.username}" valid="vtext" placeholder="请输入登录名" />
			</td>
		</tr>
		<tr>
			<td>昵称</td>
			<td>
				<input class="form-control" type="text" name="userInfo.names"
					   value="${userInfo.names}" valid="vtext" placeholder="请输入昵称"  />
			</td>
		</tr>
	<% if(isEmpty(user.ids)) { %>
		
		<tr>
			<td>密码</td>
			<td>
				<input class="form-control" type="text" name="password" readOnly="true"
					   value="" placeholder="初始密码默认为123456"  />
			</td>
		</tr>
	<% } %>
		<tr>
			<td>邮箱</td>
			<td>
				<input class="form-control" type="text" name="userInfo.email"
					   value="${userInfo.email}" valid="vtext" placeholder="请输入邮箱"  />
			</td>
		</tr>
		<tr>
			<td>手机</td>
			<td>
				<input class="form-control" type="text" name="userInfo.mobile"
					   value="${userInfo.mobile}" valid="vtext" placeholder="请输入手机"  />
			</td>
		</tr>
		<tr>
			<td>电话</td>
			<td>
				<input class="form-control" type="text" name="userInfo.telephone"
					   value="${userInfo.telephone}" valid="vtext" placeholder="请输入电话"  />
			</td>
		</tr>
		<tr>
			<td>QQ</td>
			<td>
				<input class="form-control" type="text" name="userInfo.qq"
					   value="${userInfo.qq}" valid="vtext" placeholder="请输入QQ" />
			</td>
		</tr>
	</table>

	<div style="height: 50px;clear: both;">&nbsp;</div>
	<nav class="navbar navbar-default navbar-fixed-bottom">
		<div class="container" style="padding: 5px 0px 5px 0px;text-align: center;">
			<button class="btn btn-primary" onclick="oper.save('${user.ids}');return false;">保 存</button>
			<button class="btn btn-default" onclick="closeIframe();return false;">关 闭</button>
		</div>
	</nav>
</form>
<%}; %>

<% layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){ %>
DIRECTIVE SAFE_OUTPUT_CLOSE;
<%} %>